package io操作;
import org.apache.commons.io.FileUtils;

import java.io.*;
import java.nio.file.Files;
import java.util.Arrays;

public class 数据流 {
    public static void 数据输出流() throws IOException {
        DataOutputStream out = new DataOutputStream(new FileOutputStream("数据流.txt",true));
        out.writeUTF("\r\n");
        out.writeUTF("aeiruaghp");
        out.writeInt(124);
        out.writeUTF("巧克力");
        out.close();
    }
    public static void 数据输入流() throws IOException {
        DataInputStream in = new DataInputStream(new FileInputStream("数据流.txt"));
//        System.out.println(in.readUTF());
//        System.out.println(in.readInt());
        StringBuilder sb=new StringBuilder();
        byte[] bytes=new byte[1024];
        int len;
        while ((len=in.read(bytes))!=-1){
            sb.append(Arrays.toString(bytes)).append("\r\n");
        }

        System.out.println(sb);
        in.close();
    }
    public static void main(String[] args) throws IOException {
//        数据输出流();
        数据输入流();
//        FileUtils.copyDirectory(new File("D:\\deskbook\\留校"), new File("D:\\deskbook\\留校副本"));
//        FileUtils.copyFile(new File("D:\\deskbook\\缓冲字节流.txt"), new File("D:\\deskbook\\缓冲字节流副本.txt"));
    }

}
